package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Getter
public enum OrderBizTagEnum {
    EXPIRING("expiring", "大日期订单"),
    MILK_CARD("milk_card", "奶卡订单"),
    CNY("cny", "CNY订单"),
    ;

    private final String code;
    private final String desc;

    OrderBizTagEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static List<String> codes() {
        return Arrays.stream(OrderBizTagEnum.values()).map(OrderBizTagEnum::getCode).collect(Collectors.toList());
    }

    public static OrderBizTagEnum of(String code) {
        return Arrays.stream(OrderBizTagEnum.values()).filter(source -> Objects.equals(code, source.getCode())).findFirst().orElse(null);
    }
}
